<?php
require_once("../lib/DbWrapper.class.php");
require("../libs/Smarty.class.php");
$smarty = new Smarty;
DbWrapper::dbChoice();

$nickname =$_POST["nickname"];
$mailaddress =$_POST["mailaddress"];
$password =$_POST["password"];
$admin_yn = $_POST["admin_yn"];

$smarty->assign("nickname", $nickname);
$smarty->assign("mailaddress", $mailaddress);
$smarty->assign("password", $password);
$smarty->assign("admin_yn", $admin_yn);

$error_flg = "n";
$error_nickname_yn = "n";
$error_mailaddress_yn = "n";
$error_mailaddress_already = "n";
$error_password_yn = "n";
if($nickname == ""){
    $error_flg ="y";
    $error_nickname_yn = "y";
}
if($mailaddress == ""){
    $error_flg ="y";
    $error_mailaddress_yn = "y";
}
$sql = "SELECT count(*) FROM member
        WHERE mailaddress = \"" . $mailaddress.
        "\" AND delete_yn != 'y'";
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
if($row[0] > 0){
    $error_flg ="y";
    $error_mailaddress_already = "y";
}
if($password == ""){
    $error_flg ="y";
    $error_password_yn = "y";
}
if($error_flg == "y"){
    $error_url = "http://localhost/bbs/admin/member_add_input.php?";
    if($error_nickname_yn == "y"){
        $error_url .= "&error_nickname_yn=y";
    }
    if($error_mailaddress_yn == "y"){
        $error_url .= "&error_mailaddress_yn=y";
    }
    if($error_mailaddress_already == "y"){
        $error_url .= "&error_mailaddress_already=y";
    }
    if($error_mailaddress_yn == "y"){
        $error_url .= "&error_password_yn=y";
    }

    header("Location:".$error_url);
}



$smarty->display("mamber_add_confirm.tpl");